/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.eng.scc.core.db;

import com.eng.scc.core.view.ApplicationContext;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;

/**
 *
 * @author Rafael
 */
public class ConfigurationManager
{
    public static ConfigurationManager defaultInstance = null;

    private Properties globalProperties = new Properties();
    
    private ConfigurationManager()
    {
        initPropertieValues();
    }
    
    public static ConfigurationManager getInstance()
    {
        if ( defaultInstance == null )
        {
            defaultInstance = new ConfigurationManager();
        }
        
        return defaultInstance;
    }

    private String homePath = "";
    
    private void initPropertieValues()
    {
        try
        {
            homePath = System.getProperty( "home" );
            System.out.println( homePath );
            
            globalProperties.load( new FileInputStream( homePath + 
                                                        File.separator + 
                                                        "conf" + 
                                                        File.separator + 
                                                        "global.properties" ) );
        }
        catch ( Exception e )
        {
            ApplicationContext.getInstance().saveLog( e );
        }
    }

    public String getHomePath()
    {
        return homePath;
    }

    public String getProperty( String property, String defaultValue )
    {
        return globalProperties.getProperty( property, defaultValue );
    }
}
